# -*- coding: utf-8 -*-
"""
保温杯中性策略3期 | 邢不行 | 2023分享会
author: 邢不行
微信: xbx6660
"""


def signal(*args):
    df = args[0]
    n = args[1]
    factor_name = args[2]

    df['NetBuy'] = df['taker_buy_quote_asset_volume'] * 2 - df['quote_volume']
    df['zhenfu'] = (df['high'] - df['low']) / df['low']
    df['zhenfu_mean'] = df['zhenfu'].rolling(n).mean()
    df['NetBuy_std'] = df['NetBuy'].rolling(n, min_periods=2).std()
    df[factor_name] = df['zhenfu_mean'] * df['NetBuy_std']
    del df['NetBuy']
    del df['zhenfu']
    del df['zhenfu_mean']
    del df['NetBuy_std']
    return df
